<?php

$id = I('get.id', '0', 'int');
$detail = M("shop")->field("name,startprice,announce,sendtime,sendprice,business_time,addr,is_busy,weeks,sales,sales_full,sales_cut,sales_donate")->where("id =" . $id . "")->find();
if ($detail['sales']) {
    $sales = explode(",", $detail['sales']);
    if (in_array(2, $sales)) {
        $this->assign("is_pei", 1);
    }
    if (in_array(3, $sales)) {
        $this->assign("is_piao", 1);
    }
    if (in_array(4, $sales)) {
        $this->assign("is_quan", 1);
    }
}
$cats = M("goods_cat")->field("name,id")->where("sid =" . $id . "")->order("ord ASC")->select();


foreach ($cats as $k => $v) {
    $cats[$k]['sub'] = M("goods")->field("id,name,logo,price,discount,unit,attr,intro")->where("cat_id =" . $v['id'] . " AND is_check = 1")->order("logo DESC,ord ASC")->select();
}
//print_r($cats);
$carts = json_decode(cookie("cart"), true);
foreach($carts as $k=>$v){
   $info = M("goods")->field("price,name,sid")->where("id = ".$v['id']."")->find();
    $carts[$k]['name'] = $info['name'];
    $carts[$k]['price'] = $info['price'];
    $carts[$k]['sid'] = $info['sid'];
}

$this->assign("carts", $carts);
$this->assign("cats", $cats);
$this->assign("detail", $detail);
$this->assign("id", $id);


$this->assign("is_mobile", is_mobile());
        
?>
